﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Tycho.Runtime;

namespace TychoTest {
    [TestClass]
    public class TestAnyObject {
        [TestMethod]
        public void TestStringConversion () {
            AnyObject str = "a string";

            Assert.AreEqual (RuntimeModule.CreateString ("a string"), str);
            Assert.AreEqual ("a string", (string) str);
        }

        [TestMethod]
        public void TestIntegerConversion () {
            AnyObject i = 901;

            Assert.AreEqual (RuntimeModule.CreateInteger (901), i);
            Assert.AreEqual (901, (int) i);
        }

        [TestMethod]
        public void TestBooleanConversion () {
            AnyObject b = true;

            Assert.AreEqual (RuntimeModule.CreateBoolean (true), b);
            Assert.AreEqual (true, (bool) b);
        }

        [TestMethod]
        public void TestRealConversion () {
            AnyObject r = 3.14159;

            Assert.AreEqual (RuntimeModule.CreateReal (3.14159), r);
            Assert.AreEqual (3.14159, (double) r);
        }

        [TestMethod]
        public void TestDateTimeConversion () {
            AnyObject d = new DateTime (2008, 6, 8);

            Assert.AreEqual (RuntimeModule.CreateDateTime (new DateTime (2008, 6, 8)), d);
            Assert.AreEqual (new DateTime (2008, 6, 8), (DateTime) d);
        }
    }
}
